const app = getApp()
function api(_methods,url,data,callback){
  wx.request({
      url: app.globalData.im_host + url,
      method: _methods,
      data:{...data},
      header: {
        'content-type': 'application/json',
        token: wx.getStorageSync('token')
      },
      success: (res)=>{
          typeof callback == "function" && callback(res, "");
      },
      fail: (res)=>{
          console.log('请求数据失败')
          console.log(res)
          // wx.showToast({title: '请求数据失败', icon: 'none',duration: 2000 });
          typeof callback == "function" && callback(res, "");
      }
  }); 
}
export function getJSON(url,data,callback){
  api('GET',url,data,callback)
}
export function postJSON(url,data,callback){
  api('POST',url,data,callback)
}